package cate.game.pvp.eliterace.data;


import cate.game.pvp.pointrace.data.PointRaceOpponent;
import cate.game.role.RoleSnapshot;
import lombok.Data;
import lombok.ToString;

@ToString
@Data
public class EliteRaceOpponent {

    private int prRank;

    private RoleSnapshot snapshot;
    private long points;

    private int winCount;
    private int looseCount;

    public static EliteRaceOpponent ofCopy(RoleSnapshot snapshot, long points) {
        return of(snapshot, points, true);
    }

    public static EliteRaceOpponent ofNoCopy(RoleSnapshot snapshot, long points) {
        return of(snapshot, points, false);
    }

    public static EliteRaceOpponent of(RoleSnapshot snapshot, long points, boolean copy) {
        EliteRaceOpponent opponent = new EliteRaceOpponent();
        opponent.setSnapshot(copy ? snapshot.copy() : snapshot);
        opponent.setPoints(points);
        return opponent;
    }

    public static EliteRaceOpponent of(PointRaceOpponent pOpp, int prRank) {
        EliteRaceOpponent eOpp = new EliteRaceOpponent();
        eOpp.setSnapshot(pOpp.getSnapshot());
        eOpp.setPrRank(prRank);
        eOpp.setPoints(pOpp.getPoints());
        return eOpp;
    }


    public void win(boolean count, long points) {
        if (count) {
            this.winCount++;
        }
        this.points += points;
    }

    public void loose(boolean count) {
        if (count) {
            this.looseCount++;
        }
    }
}
